﻿#region References
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using JigLibX.Collision;
using JigLibX.Physics;
using JigLibX.Geometry;
using JigLibX.Math;
using Microsoft.Xna.Framework.Graphics;
using Xen;
#endregion

namespace Ness.Engine.Entities.Primitives
{
    /// <summary>
    /// A simple prop with "box" collision data
    /// </summary>
    class BoxObject : Prop
    {
        /// <summary>
        /// A simple prop with "box" collision data
        /// </summary>
        /// <param name="game">The current game instance</param>
        /// <param name="model_path">The model path relative to Content</param>
        /// <param name="sideLengths">Vector3 length of the sides (collision only)</param>
        /// <param name="orientation">Matrix orientation - usually Matrix.Identity</param>
        /// <param name="position">Vector3 position relative to world</param>
        public BoxObject(Engine game, string model_path, Vector3 sideLengths, Matrix orientation, Vector3 position)
            : base(game, model_path, true, false)
        {
            body = new Body();
            collision = new CollisionSkin(body);
            body.CollisionSkin = this.collision;

            collision.AddPrimitive(new Box(-0.5f * sideLengths, orientation, sideLengths), new MaterialProperties(0.8f, 0.8f, 0.7f));

           // Vector3 com = SetMass(1.0f);
            body.MoveTo(position, orientation);
           // collision.ApplyLocalTransform(new Transform(-com, Matrix.Identity));
            game.physicSystem.CollisionSystem.AddCollisionSkin(collision);

            body.EnableBody();

            this.scale = sideLengths;
        }
    }
}
